/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AboutBox.java
 *
 * Created on Apr 17, 2011, 1:41:42 AM
 */

package jgaf.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

/**
 *
 * @author hanis
 */
public class AboutBoxDialog extends javax.swing.JDialog {

    /** Creates new form AboutBox */
    public AboutBoxDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        //setNames();

        setModalityType(ModalityType.APPLICATION_MODAL);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        centerDialog();
        setVisible(true);
    }

    private void centerDialog() {
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - this.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - this.getHeight()) / 2);
        this.setLocation(x, y);
    }

//    private void setNames() {
//        setTitle(jgaf.l18n.Resource.getValue("main.dialog.about.title"));
//        labelName.setText(jgaf.l18n.Resource.getValue("main.dialog.about.name"));
//        labelFullName.setText(jgaf.l18n.Resource.getValue("main.dialog.about.fullName"));
//
//        JTextArea textDescription = new JTextArea();
//        textDescription.setText(jgaf.l18n.Resource.getValue("main.dialog.about.description"));
//        textDescription.setBorder(new EmptyBorder(5, 10, 5, 10));
//        textDescription.setLineWrap(true);
//        textDescription.setWrapStyleWord(true);
//       // textDescription.setFont(new Font("Helvetica", Font.BOLD, 12));
//        textDescription.setEditable(false);
//        textDescription.setBackground(getBackground());
//        descriptionPanel.setLayout(new BorderLayout());
//        descriptionPanel.add(textDescription, BorderLayout.CENTER);
//
//       // textDescription.setBackground(getBackground());
//        labelVersion.setText(jgaf.l18n.Resource.getValue("main.dialog.about.version"));
//        buttonClose.setText(jgaf.l18n.Resource.getValue("buttons.close"));
//    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        labelName = new javax.swing.JLabel();
        labelVersion = new javax.swing.JLabel();
        labelName1 = new javax.swing.JLabel();
        buttonClose = new javax.swing.JButton();
        labelVersion1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("About");

        jPanel1.setBackground(new java.awt.Color(254, 254, 254));

        labelName.setFont(new java.awt.Font("Arial", 1, 36));
        labelName.setText("JGAF");

        labelVersion.setText("version 1.0.1");

        labelName1.setFont(new java.awt.Font("Arial", 1, 24));
        labelName1.setText("Java Grammars and Automata Framework");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelName)
                    .addComponent(labelName1)
                    .addComponent(labelVersion))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelName)
                .addGap(13, 13, 13)
                .addComponent(labelName1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelVersion)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonClose.setText("Close");
        buttonClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCloseActionPerformed(evt);
            }
        });

        labelVersion1.setText("Project is hosted at http://code.google.com/p/jgaf/");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(439, Short.MAX_VALUE)
                .addComponent(buttonClose)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelVersion1)
                .addContainerGap(130, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelVersion1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonClose)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed
        dispose();
    }//GEN-LAST:event_buttonCloseActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AboutBoxDialog dialog = new AboutBoxDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonClose;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel labelName;
    private javax.swing.JLabel labelName1;
    private javax.swing.JLabel labelVersion;
    private javax.swing.JLabel labelVersion1;
    // End of variables declaration//GEN-END:variables

}
